refactored gamma code and BATTLE