Implement the isInside logic