reorder to reduce amount of code a bit