move more functions to better locations