optimize add colored ball logic