black balls and red-flag logic done