completed function that checks whether current state matches expected state