Refactored code, more elegant.