broke up files some more, added a better typechecking function