improved script by using ranges instead of if x >= 5 && x <= 10