move functions to relevant locations