refactor and add first solving algorithm