modularized all but one reuqest handler, modified variable names to work with new db