move locate_head() to remote.c