api: shorten function checks (and put each into a different scope)