changed the locations of several functions to more sensible locations