Refactored code - more tidy