re-organise frame and updated example based on re-organised code