added input validation to pagination