refactored the code in a seperate file, went from 57 > 35 lines