Adds function to do something on selection