code updated, logging added