Added logic checking for initiating script