FIX: max was not being used correctly, fixed