add map end logic to