fixed bug with defining functions