integrating with jasons code
refactoring