Updated neighdens algorithm with more parameters

needs more testing!