continue to refactor
fix protential mem leak