renamed & rearranged function names