updated to new array & dictionary syntax and sorted method