further string extraction and refactoring until line 1832