optimize 'print' and removed redundant lines