Feature/segment validation

This pull requests adds exception handling for invalid segments created by users