refactored to use upto method