fixed bug in bounds handling