refactor code in base