refactor: extracting the whole compilation logic from the viewmodel