Refactored code a bit.
Refactored code a bit.