more refactoring of low level api