Trying to solve Fatal error: Using $this when not in object context .