rewrite selection mechanism
code cleaning
code cleaning
fix #5