Fixed definition of some functions