fifo refactor