fixed inconsistent tabbing
optimize all code