fixed a bug in the  check function