resolve bugs and esc function