Made some modifications to script