added log statements for debugging
fixed indent