added AND/OR logic