refactor: remove repeated function