moved function to top