refactore code after chat with main contributor