cleaning up code, added log