add transition and refactor