Adding control logic
Fixing fifo