Corrected some DB query code and added few lines to output.