fixed loop head recognition (hopefully)