implemented proximity detection