end logic