altered code to prevent duplicate names