fix frontend
improve sql query construction; actually pass results to template for rendering