Function sometimes doesn't get drawn. Fixing this.