Refactored code maybe