ball doubling code seems to work properly