Refactored as advised.