Gain calc

- gain calc..
- bm array filling
- tolerance check..