Rearranged the order of the function calls