refactor: clear repeated code.