rearranged some functions