Fixing issue of printing if statements