20140211 refactor some code