initial function revised per instructions