Implemented better logging