Rewrite print function

Signed-off-by: Oleg Bulatov <oleg@bulatov.me>