changed loop to big ugly if to make script work properly (dont ask, dont know)