Move script tags to solve undefined errors