Added additional input validation