refactoring, to have persistent mode

Signed-off-by: Thiago Rondon <thiago.rondon@gmail.com>
typo in while

Signed-off-by: Thiago Rondon <thiago.rondon@gmail.com>
fix _log

Signed-off-by: Thiago Rondon <thiago.rondon@gmail.com>