Added code to handle names rather than indexes

It is way more readable