finished min implementation for b
bugs seem to be eliminated