made code simpler by calling sql and print