complete rewrite to make it more modular and useful
logger[todo] and additional utils