rearranged the code slightly