improved the script