Set self outside function

Fix a bug in specific context where this isn't available inside the
function