added switch ball function