Inner join made more generic