added better history handling and confirmation box