try to refactor code