adding logging information, refactor coding