cleaned up proximity code and added some code