added mutex to database handling