Moved functions to a better location

Moved functions to a better location