need to externalise the join function