added log statements, fixed indents