updated with ball detection