refacored logging