completed the script to retrieve data