Change to code to try and avoid a static call in a function using $this.