fixed bug with incorrect range