refactor and remove favor legacy code