reorder thunks code a bit