more robust function + type searching - see #47