Fixed code for functions.