fixed error caused by missing "then"