updating frame writing function