Added beginTransaction before commit