sweep2wake: relocate code to the correct position