refactor and use osgl-tool