Rearranged the code: better?