adding invalid frame handling, #47