The legal status of third country nationals resident in the European Union