added canvas refresh function