working version but might need to improve clock crossing on FIFO