use masks for checking passability