moved funciton prototypes to more logical places