first draft of frame grabbing function; needs test