indent code and remove redundant code