implemented flood fill algorithm