updating code to deal with normalized data rather than one-to-many relationships