changed conditional logic