Fixed error in db transactions