Fixed 'this' function scope issue