Added check on input variables