add remove code to event listener;remove infinit loop which may casue program death