now script works fine