Updated Script for more functionality