Function to check neighbourhood