properly encapsulated the code for the scrpt queuing