Refactored

Removed if statements and while loop, replaced with looping thru hash