tweaked the name sorting function