Moved all the service calls inside the script block.