tidy and merge moveable code