[api] beautify the code a bit