Encapsulate tap initializetion and callback setting into a function.