fixed a bug when pressing "res" button