several changes and refactor, test finished!