Even though this is an old snippet, it could've been shortened a lot more to be efficient...just like DarthRaven had pointed out.