fix a bug and an exception