Fix incorrect use of 'this' inside anonymous function