updated cleandb function