moving detectballs to own function