moved around some functions