support https
avoid error where lastState is undefined