Hi Andrew,

The logic is ambiguous in that it picks the first non-zero layout_id.  Currently, there is only the possibility of one instantiated layout_id.  Althought the db can handle different layout ids for each profile, the code isn't setup to handle more than one.  If the layout isn't instatiated/saved, it is set to 0 and if it is saved it is 1 in the profile.  I didn't like hardcoding 1 although it is hardcoded in at least one other place.  I can add a comment to the effect that only one layout id is supported and this being the reason for looking to see if any of the profiles has a layout that has been instantiated/saved.

I will refactor this out this logic into its own method as suggested.  I will most likely set it to a variable to then leverage the variable to build the returned profile and set the sql statement parameter.

Thanks for this review and feedback :)
Shawn