Moved function to proper place