refactor sql calls using a sqlhelper and json helper module