correct the order of fn definitions