Script corrected, now works well