fixed wrong range() usage