Fixed a bug in functions.