added log & error handling stuff