refactored some code; added sample db call