Shouldn't this be attached to render event?