max amount logic