fixed cleaning up credentials before storing a new one