Added smart AND OR soloution