modified dialog code