added type check for function calls