refactored and reorganized the code
added a selection feature with I / O (in / out markers)