fixed cleaning up the database