Removed the use of "$this" inside closures as it will not work and cause fatal error.