refactored code to sprite file