refactor and deprecate some code