rearranging code for one .cpp file