inlined some functions