gracefully handling relaxmap segmentation error, a little refactoring