The same for all modes, move to the top of the function.