Making isSolution a nested function