Add oath js for queries
Tidy up and organise methods from main