Fix generateNewTitle function