Added query coding
Fixing and Putting in javascript