Function endFrame