Added the correct database lookups

Should be in a working state now.  Fingers crossed.