make the isXXX functions pure
remove some code duplications