pseudo code of checking