added logging and comments
removed obsolte sysouts