started writing BF algorithm