refactored calculations; added setRelation determination