bugfix passed db handle to function