Final Code for Script