updating the esr query and also adding in some changes for deployment on server