fix logic bug in HEAD_PLUS_LATEST code