Fixed some issues with the script not working