move script from tail to header