formatted, add many TODOs and add getTypesafeQuery method