refactored and added or logic