split off some code