added relation detection, fixed #5