Refactored code.. made it a bit cleaner