fixed safari bug by moving script to top