Now the script completely works