improved the script
more fixes