refactor to split up into seperate files