Fixed bug in local detection