rearranged certain fuctions