moved functions to start of parent function