wrote grab and set function