please adjust the previous code's indentation with if conditions