factored out frame function