correct check if db is opened avoiding commit if it's closed
bug on comparing team_id