Fix wrong indent and rework some logic (#401)