Completed code for hub pairing