refactored to not use internal API