removed log call
renamed occurance of db variable to be more reflective of its actual contents
refactored the way resources are threaded along to be more clear