Rewritting neighbors funciton