Refactored the fucntions to different files, generified them