fixed logic for variable checking in controllers