retrieve function

Made, tested, and commented the retrieve function.