working version on fpga