logging fix and remove redundant code