code structure refactor