implementing compare operations (please do not refactore the code: it's WIP) ref #191