Changed functions to refer to self