Moved function to more logical location