fixed database overwriting issues