Reworked for python2 and cli