Fixed few issues with the script