Modularizes querying and sending information to back to client to minimize duplicate code. Adds JSDoc3 documentation to functions