Made script more stable