better handling of functions