change some naming, move code around