rewrite for cleaner codes
Merge pull request #210 from NFLabs/minor-refactor

rewrite for cleaner codes