added proper handling for and and or