added function to print names with indices