clean up where functions are defined

and declared