Move function to fix javascript error