refactored db functions, corrected wp config issue