Add null check on input cleaning