Code refactored a little.