small simplification
moved code around