fixed bug where "self" is not defined.