add st3 support and refactor some codes