Refactored code to use the helper methods from Imagination Framework