moved functions to cpp file