Added some validation for the input parameters