Implemented error logging