improve internal function