Made sure that it ignores non-existsting neighbours while computing mean value.