refactor and fmt