fix the order of hooks
slight performance improvement