Backfiring problem

Got a s14 240sx with a sr20det, when accelerating the engine light is flashing on and off and when you hit 5000 rpm and keep going the engine backfires. Im positive its not a timing problem becuase the car only acts up at a high rpm and it idles fine, i think its a fuel air problem, maybe related to the mass air sensor?

nvm, traced all the vaccuum lines, broken line, no issues