Cleanup getTitle function