Sword working

Sword working and some code's generalization made