moved script out of main