added backup for mainalgorithm