functions rearranged