finished up reordering functions and lemmas