reordered the functions to make sure that they work.