replace gmax var from 7 to 17