Added validation of input parameters