alternate version of flood fill based on commentary from reddit discussion