fixed problem that the script gets executed many times.