refactor reuse code