refactor of upto