state transitions in process_frame function