make sure offset is not negative