refactor select operation and some code style