added rangeBound function