propose to put for (Map ...) into if clause

in current implementation log.trace will be not executed