Code optimization
Add junit tests