refactored db function into module. Using mashape oauth module