added input validation for quantity